Ext.define('Jee.view.CURDToolbar',{
    extend : 'Ext.toolbar.Toolbar',
    alias : ['curdToolbar'],
    dock:'top',
    searchButton:{text:'查询',id:"searchButton",iconCls: 'search',serviceId:'05'},
    addButton:{text:'增加',iconCls:'add',serviceId:'03'},
    editButton:{text:'编辑',iconCls: 'edit',serviceId:'02'/**,disabled: true*/},
    deleteButton:{text:'删除',iconCls: 'delete',serviceId:'01'},
    
    initComponent : function(){
	  this.buildItem();
      this.callParent();
    },
    
    buildItem:function(){
      var items =['->'];
	  var me = this;
	  this.searchButton.handler = function(){
		  var condition;
		  if(me.grid.conditionView){
			   var form = me.grid.conditionView.getForm();
			   condition = form.getValues(); 
		  }
		  me.grid.searchRecord(me.grid.serviceClassCode+'_'+me.searchButton.serviceId,condition);
	  };
	  items.push(this.searchButton);
	  items.push('-');
	  
	  this.addButton.handler = function(){
		 me.grid.addRecord();
	  };
	  items.push(this.addButton);
	  items.push('-');
	  
	  this.editButton.handler = function(){
		  me.grid.editRecord(me.grid.serviceClassCode+'_'+me.editButton.serviceId);
	  },
	  items.push(this.editButton);
	  items.push('-');
	  
	  this.deleteButton.handler = function(){
		  me.grid.deleteRecord(me.grid.serviceClassCode+'_'+me.deleteButton.serviceId);
	  },
	  items.push(this.deleteButton);
	  if(me.grid.conditionView){
		   items.unshift(me.grid.conditionView);
	  }
	  this.items = items;
    }
});